package com.account.dao;

import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.classic.Session;

import com.account.basedao.BaseDAO;
import com.account.entity.Login;
import com.account.interfaces.ILogindao;

public class LoginDAO extends BaseDAO implements ILogindao {
	boolean result;

	@Override
	public boolean isLoginValid(String username, String password) {
		AnnotationConfiguration annotationConfiguration = getConfiguration();
		SessionFactory sessionFactory = annotationConfiguration.buildSessionFactory();
      Session session = getSession(sessionFactory);
      Transaction transaction =getTransaction(session);
      Object object = session.get(Login.class, new String("username"));
            Login login= (Login)object;
           /* if((login.getUsername()).equals(username)){
            	result=true;
            }else{
            	result=false;
            }*/
            System.out.println(login);
        	close(sessionFactory, session, transaction);
            return result;
		
	}
	public static void main(String[] args) {
		LoginDAO dao = new LoginDAO();
		System.out.println(dao.isLoginValid("username", "password"));
	}

}